<?php 
session_start();

$user = $_SESSION['username'];
if (!$user) { header('location: login.php'); exit; }

include "../../includes/functions.php";

echo db_connect();

 ?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>CJLY ADMINISTRATION</title>
<link href="../../css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" media="screen" href="../../includes/themes/coffee/grid.css" /> 
<link rel="stylesheet" type="text/css" media="screen" href="../../includes/themes/jqModal.css" /> 

<script type="text/javascript" src="../../calendar_picker_submit.js"></script>
<script type="text/javascript" src="../../includes/jquery.js"></script>
<script type="text/javascript" src="../../includes/jquery.jqGrid.js"></script>

<link rel="stylesheet" type="text/css" media="screen" href="themes/ui.datepicker.css" />
<script src="../../includes/ui_datepicker/ui.datepicker.js" type="text/javascript"></script>


<script src="../../includes/js/jqModal.js" type="text/javascript"> </script>
<script  src="../../includes/js/jqDnR.js" type="text/javascript"> </script>


<script type="text/javascript">

function pickdates(id){
	jQuery("#"+id+"_sdate","#rowed6").datepicker({dateFormat:"yy-mm-dd"});
}



// We use a document ready jquery function.
jQuery(document).ready(function(){
	var lastsel2;
	jQuery("#list1").jqGrid({
		url:'_spots_grid.php?q=1',
		datatype: "xml",
		colNames:['ID', 'Track #','Title','Text','Type', 'Start Date', 'End Date', 'Delete'],
		colModel:[
			{name:'id',index:'id', width:5, hidden:true},
			{name:'track_number',index:'track_number', width:40, sortable:false,editable: true,edittype:"text"}, 
			{name:'title',index:'title', width:200,sortable:false,editable: true,edittype:"textarea", editoptions:{rows:"1",cols:"40"}},
			{name:'text',index:'text', width:250,sortable:false,editable: true,edittype:"textarea", editoptions:{rows:"6",cols:"40"}},
			{name:'type',index:'type', width:40, sortable:false,editable: true,edittype:"select", editoptions:{value:{MP3:'MP3',Text:'Text'}}},
         {name:'start_date',index:'start_date', width:70, sortable:false,editable: true,sorttype:"date"},
			{name:'end_date',index:'end_date', width:70,sortable:false,editable: true,edittype:"text"},

			{name:'act',index:'act', width:20,sortable:false}
		],
		rowNum:500,
		rowList:[50,100,200],
		imgpath: 'http://66.118.188.130/*cjly.ca/httpdocs/includes/themes/coffee/images',
		//pager: jQuery('#pager1'),
		sortname: "title",
		viewrecords: true,
		sortorder: "desc",
		caption:"SPONSORSHIP SPOTS - Click to edit, Return to save.",
		editurl:"_save_grid.php",
		
		
		loadComplete: function(){
		var ids = jQuery("#list1").getDataIDs();
		for(var i=0;i<ids.length;i++){
			var cl = ids[i];
			be = "<input style='height:22px;width:20px;' type='button' value='X' onclick=jQuery('#list1').delGridRow("+cl+"); ></ids>";
			jQuery("#list1").setRowData(ids[i],{act:be})
		}	
	},
		
		
		onSelectRow: function(id){
      if(id && id!==lastsel2){
        jQuery('#list1').restoreRow(lastsel2);
        jQuery('#list1').editRow(id,true);
          lastsel2=id;
      }
    }
  
	}); 

}).navGrid("#list1",{edit:false,add:false,del:false});



///////////////
/*
jQuery("#rowed2").jqGrid({
   	url:'server.php?q=3',
	datatype: "json",
   	colNames:['Actions','Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
   	colModel:[
		{name:'act',index:'act', width:75,sortable:false},
   		{name:'id',index:'id', width:55},
   		{name:'invdate',index:'invdate', width:90, editable:true},
   		{name:'name',index:'name', width:100,editable:true},
   		{name:'amount',index:'amount', width:80, align:"right",editable:true},
   		{name:'tax',index:'tax', width:80, align:"right",editable:true},		
   		{name:'total',index:'total', width:80,align:"right",editable:true},		
   		{name:'note',index:'note', width:150, sortable:false,editable:true}		
   	],
   	rowNum:10,
   	rowList:[10,20,30],
   	imgpath: gridimgpath,
   	pager: jQuery('#prowed2'),
   	sortname: 'id',
    viewrecords: true,
    sortorder: "desc",
	loadComplete: function(){
		var ids = jQuery("#rowed2").getDataIDs();
		for(var i=0;i<ids.length;i++){
			var cl = ids[i];
			be = "<input style='height:22px;width:20px;' type='button' value='E' onclick=jQuery('#rowed2').editRow("+cl+"); ></ids>"; 
			se = "<input style='height:22px;width:20px;' type='button' value='S' onclick=jQuery('#rowed2').saveRow("+cl+"); />"; 
			ce = "<input style='height:22px;width:20px;' type='button' value='C' onclick=jQuery('#rowed2').restoreRow("+cl+"); />"; 
			jQuery("#rowed2").setRowData(ids[i],{act:be+se+ce})
		}	
	},
	editurl: "server.php",
    caption:"Custom edit "
}).navGrid("#prowed2",{edit:false,add:false,del:false});
*/
///////////////////////






jQuery.jgrid.edit = {
    addCaption: "Add a Spot",
    editCaption: "Edit Spot",
    bSubmit: "Submit",
    bCancel: "Cancel",
    processData: "Processing...",
	closeAfterAdd:"true",
	
    msg: {
        required:"Field is required",
        number:"Please enter valid number!",
        minValue:"value must be greater than or equal to ",
        maxValue:"value must be less than or equal to"
    }
	
	
};


</script>






<script type="text/javascript">
function validate()  {

	if (document.form1.show_id.value == 0) {
	alert ("Please select a show to create a playlist for");
	return false;
	} else {  return true; }

	
}
</script>
</head>

<body bgcolor="#eeeeee">
<a href="index.php"><< ADMINISTRATION Home</a> 
<table width="750" height="60" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="4" class="index_table_hed"><div align="center">SPONSORSHIP SPOTS</div></td>
  </tr>

</table>
<p>
<div>
<br>
<form action="sponsorship_schedule.php" name="goToDate" method="GET">
  Schedule Sponsorship Spots:<br /><input name="lkdate" type='hidden'>
<input type=button value="Choose Date" onclick="displayDatePicker('lkdate');">
</form>
</div></p>
<p>&nbsp;</p>
<p>&nbsp; </p>
<table id="list1" class="scroll" cellpadding="0" cellspacing="0"></table>
<input name="Add New Spot" value="Add New Spot" type="button" onClick='jQuery("#list1").editGridRow("new", "closeAfterAdd:true, addCaption:Add a new spot, width:800, height:400");' />
</body>
</html>
